Goal:

Think, explore, & write about what the co-evolutionary interaction between newts & snakes with different genetic architectures (GAs, combination of mutation rate & mutation effect size) can lead to. This markdown is investigation what is up with the different levels of correlation between rectangles and squares. After fixing the row vs column error I looked at the correlation data and found that there was less correlation. So I decided to investigate why that might be and run a few more experiments. I am running an experiment to test how changing the square size might impact the calculations. I also plan on changing the interaction rate (but want to look at the math/ feasibility of it). This file contains results discussed in Tall_GA1!

Questions:

What does it mean to be correlated?

Background

I investigated the correlations between snake and newt phenotypes at the local grid locations along with population level phenotype. I found there was a lot of correlation when populations slowly adapt! However, after a closer investigation I found that these correlations were from a rectangle shaped area and not a square one. Here, I rerun the experiment with he correct square grids and discuss how the results differ. I also aim to investigate how changing the area/shape of the grids will influence correlation results. I am also thinking of ways to gather and incorperate allele information.

Experiment

I created a simulation study to observe the co-evolutionary outcome of the newt-snake interaction with different genetic architectures (GAs) in a spatial setting. I hypothesized that we would see an interaction (co-evolutionary arms race) between newt and snake phenotype under some GA combinations when newts and snakes were evolving over geographical space. Each GA is paired with another GA creating 16 combinations.

GA1 experiment values:

Landscape: 20 by 5 grid. A tall map!: 354 H, 35 W New Landscape 28 by 7 grid: 354 H, 35 W

The data

I gather text file data from different files and have to do some table wrangling to get it into a format I can graph. I use information gathered from the entire population; data containing a mean value for the entire map (lit), correlation data based off of local populations that were divided into grids (cor) and data collected from grid based populations (grid). These simulations have a msprime (coalescent/burn in/random genetic variation) and then run for 50,000 generations in SLiM (co-evolution) (all with the same GA values). I run 4 trials for every GA combination and try two different grid sizes 20 by 5 (large) and 24 by 7 (small) in SLiM. These slim simulations use the same msprime simulation, but can statistically be different.

## All cor, lit, and grid files exist!
## This program will now end!

Important files GA1_tall_tall_file GA1_cor_tall_file GA1_grid_tall_file GA1_tall_tall_7_file GA1_cor_tall_7_file GA1_grid_tall_7_file

Mean Phenotype Whole Simulation

First, I will look at a plot of how the mean phenotype of the entire population of newts and snakes changes overtime. Each of these plots has three colored lines, red for the mean newt phenotype, blue for the mean snake phenotype, and black for the difference between mean snake and mean newt phenotype. There are 4 line per color that represent the different replicas that I ran. Note this is a mean for the entire population. Mutational variance increases for the snakes as you go down the figure (top to bottom) and increases for the newts as you go across (left to right).

Phenotype differences (5 sec)

Table of average Differences (5 sec)

##                    Group.1          x
## 1  1e-08_0.005_1e-08_0.005  0.1228741
## 2   1e-08_0.005_1e-09_0.05 -1.9048949
## 3    1e-08_0.005_1e-10_0.5 -2.8179176
## 4      1e-08_0.005_1e-11_5 -0.4003216
## 5   1e-09_0.05_1e-08_0.005  2.7018939
## 6    1e-09_0.05_1e-09_0.05 -0.5188002
## 7     1e-09_0.05_1e-10_0.5 -1.1922474
## 8       1e-09_0.05_1e-11_5  0.4028800
## 9    1e-10_0.5_1e-08_0.005  1.8949091
## 10    1e-10_0.5_1e-09_0.05 -0.2873013
## 11     1e-10_0.5_1e-10_0.5 -0.4165329
## 12       1e-10_0.5_1e-11_5  0.3512759
## 13     1e-11_5_1e-08_0.005  0.1343393
## 14      1e-11_5_1e-09_0.05 -1.2582723
## 15       1e-11_5_1e-10_0.5 -1.3798476
## 16         1e-11_5_1e-11_5 -0.6589529

Phenotype differences (7 sec)

Table of average Differences (7 sec)

##                    Group.1           x
## 1  1e-08_0.005_1e-08_0.005  0.13112840
## 2   1e-08_0.005_1e-09_0.05 -2.39679271
## 3    1e-08_0.005_1e-10_0.5 -2.73768918
## 4      1e-08_0.005_1e-11_5 -0.25055622
## 5   1e-09_0.05_1e-08_0.005  2.61270891
## 6    1e-09_0.05_1e-09_0.05 -0.70695433
## 7     1e-09_0.05_1e-10_0.5 -1.14717140
## 8       1e-09_0.05_1e-11_5  0.38920777
## 9    1e-10_0.5_1e-08_0.005  2.10180688
## 10    1e-10_0.5_1e-09_0.05 -0.08745614
## 11     1e-10_0.5_1e-10_0.5 -0.36972292
## 12       1e-10_0.5_1e-11_5  0.43034445
## 13     1e-11_5_1e-08_0.005  0.56986732
## 14      1e-11_5_1e-09_0.05 -1.26474530
## 15       1e-11_5_1e-10_0.5 -1.46086858
## 16         1e-11_5_1e-11_5 -0.82308506

Connection between higher phenotype and population (5 sec)

Notes

Phenotype differences

Phenotype & Populationsize differences

Connection between higher phenotype and population (7 sec)

Notes

Phenotype differences (7 sec)

Phenotype & Populationsize differences (7 sec)

I looked at the results between 5,000 - 10,000 generations where I saw most of the increase in newt and snake phenotype. The first plot has newt population size by snake population size with the color representing the difference between snake and newt mean phenotype (red=newts have a higher mean phenotype, blue=snakes have a higher mean phenotype). The third GA (an intermediate one) seems to do better then all of the other GAs (blue row (3), red column (3)). However, this is dependent on the point in the simulation you focus on. The next two plots show the difference between snake and newt population size (green) and phenotype (purple). For the most part these suggest that when the mean phenotype is higher so is the population size. This also shows the asymmetrical nature between the predator-prey interaction (higher max population sizes seen in snakes). The population size is also more variable than the phenotype (difference in population size has a wider range).

Correlation

The next section I aim to look at how correlated newt and snakes are at local populations across the geographical area. I am examining correlation between newt and snake phenotypes, population sizes of newts and snakes, amount of toxin and snake population, and the amount of resistance and newt population size. I predicted that there would be a positive correlation between the phenotypes, and a negative correlation between population sizes, and the amount of toxin/resistance and population size. Below is a legend for the first two plots. The third plot is colored by trial.

I first look at the correlation between mean newt phenotype and mean snake phenotype for each of the four trials in every GA combination from 10,000-15,000 generations. The solid line is a 0 with a dashed line at the level of correlation seen in natural newt-snake population(s). The second figure shows the the results of all 4 trials for each correlation measurement I made from 10,000-15,000 generations. The third plot takes the information from the fist plot and shows the distribution of correlation values by each trial (solid line at 0, dashed line at real newt-snake correlation).

Five sections

Seven sections

After looking at this figure, I can see that there is a larger range of correlation values. The can sometimes be positive, near 0, or negative. Very few reach (or come near) the real newt-snake correlation. How do you find the correct time slice to look for spatial correlation? How would these phenotypes become spatially correlated and then become not spatially correlated.

Correlation Histograms (5 sec)

In order to understand how spatial correlations where changing with time I took 5,000 generation time slices to look at all four trials correlation values. Each color is a different trial per GA combination. The histogram values are stacked.

Plot 1

Plot 2

Plot 3

Plot 4

Plot 5

Plot 6

Plot 7

Plot 8

Plot 9

Plot 10

Correlation Histograms (7 sec)

In order to understand how spatial correlations where changing with time I took 5,000 generation time slices to look at all four trials correlation values. Each color is a different trial per GA combination. The histogram values are stacked.

Plot 1 (7 sec)

Plot 2 (7 sec)

Plot 3 (7 sec)

Plot 4 (7 sec)

Plot 5 (7 sec)

Plot 6 (7 sec)

Plot 7 (7 sec)

Plot 8 (7 sec)

Plot 9 (7 sec)

Plot 10 (7 sec)

Correlation across time

notes

Random 1 (5 sec)

Random 2 (5 sec)

## [1] "pattern 1e-11_5_1e-10_0.5_1"
## [1] "Cor between average snake pheno and local cor -0.0314060463750889"
## [1] "Cor between average newt pheno and local cor 0.00810297374558884"
## [1] "Cor between average dif pheno and local cor -0.0648198431335265"
## [1] "Cor between newt pheno and snake 0.811525316090738"

Random 3 (5 sec)

## [1] "pattern 1e-08_0.005_1e-08_0.005_1"
## [1] "Cor between average snake pheno and local cor 0.3733304670777"
## [1] "Cor between average newt pheno and local cor 0.326696896375133"
## [1] "Cor between average dif pheno and local cor 0.361899546136465"
## [1] "Cor between newt pheno and snake 0.795578851089615"

Random 1 (7 sec)

## [1] "pattern 1e-09_0.05_1e-11_5_3"
## [1] "Cor between average snake pheno and local cor 0.426885987029011"
## [1] "Cor between average newt pheno and local cor 0.37727850183199"
## [1] "Cor between average dif pheno and local cor 0.0213990051869683"
## [1] "Cor between newt pheno and snake 0.948882972249104"

Random 2 (7 sec)

## [1] "pattern 1e-09_0.05_1e-11_5_1"
## [1] "Cor between average snake pheno and local cor 0.00738423923360094"
## [1] "Cor between average newt pheno and local cor -0.0812305838120983"
## [1] "Cor between average dif pheno and local cor 0.218035609626229"
## [1] "Cor between newt pheno and snake 0.914869435565593"

Random 3 (7 sec)

## [1] "pattern 1e-09_0.05_1e-08_0.005_0"
## [1] "Cor between average snake pheno and local cor -0.113606417425076"
## [1] "Cor between average newt pheno and local cor 0.114932002305195"
## [1] "Cor between average dif pheno and local cor -0.154973656506681"
## [1] "Cor between newt pheno and snake 0.333820567947072"

What happens over time (looking at the beginning, middle, and late part of my simulations)

This next section is just getting a glimpse at how newt & snake phenotype and population size differ over time. The populations start off with about 250 individuals each. Each individual has a different genetic background created from msprime.

Pheno Beginning

Pheno Middle

Pheno End

Dif Beginning

Dif Middle

Dif End

What happens over time (looking at the beginning, middle, and late part of my simulations) (7 sec)

This next section is just getting a glimpse at how newt & snake phenotype and population size differ over time. The populations start off with about 250 individuals each. Each individual has a different genetic background created from msprime.

Pheno Beginning (7 sec)

Pheno Middle (7 sec)

Pheno End (7 sec)

Dif Beginning (7 sec)

Dif Middle (7 sec)

Dif End (7 sec)

explane

Summary

notes

Early-Sim Population Size Summary

Mid-Sim Population Size Summary

Late-Sim Population Size Summary

Early Difference Summary

Mid Difference Summary

Late Difference Summary

By Snake GA (Early)

By Snake GA (Mid)

By Snake GA (Late)

By Newt GA (Early)

By Newt GA (Mid)

By Newt GA (Late)

Summary (7 sec)

notes

Early-Sim Population Size Summary (7 sec)

Mid-Sim Population Size Summary (7 sec)

Late-Sim Population Size Summary (7 sec)

Early Difference Summary (7 sec)

Mid Difference Summary (7 sec)

Late Difference Summary (7 sec)

By Snake GA (Early) (7 sec)

By Snake GA (Mid) (7 sec)

By Snake GA (Late) (7 sec)

By Newt GA (Early) (7 sec)

By Newt GA (Mid) (7 sec)

By Newt GA (Late) 7

expla

Heatmap

notes

Population Size (Early)

Population Size (Mid)

Population Size (Late)

Phenotype (Early)

Phenotype (Mid)

Phenotype (Late)

Heatmap (7 sec)

notes

Population Size (Early) (7 sec)

Population Size (Mid) (7 sec)

Population Size (Late) (7 sec)

Phenotype (Early) (7 sec)

Phenotype (Mid) (7 sec)

Phenotype (Late) (7 sec)

What is up with the correlations

file_name= “Snake_1e-09_0.05_Newt_1e-09_0.05_2” file_name= “Snake_1e-08_0.005_Newt_1e-08_0.005_3” file_name= “Snake_1e-09_0.05_Newt_1e-09_0.05_2”

What is up with the correlations

notes

Early Simulation Correlation

Mean

## [1] 0.4282603

SD

## [1] -0.05794028

Max Phenotype

## [1] 0.4025511

Min Phenotype

## [1] 0.242993

Population Size

## [1] -0.2920976

Middle Simulation Correlation

Mean

## [1] -0.0140173

SD

## [1] 0.2180298

Max Phenotype

## [1] 0.1438674

Min Phenotype

## [1] 0.01899735

Population Size

## [1] 0.3874851

Late Simulation Correlation

Mean

## [1] 0.30277

SD

## [1] 0.2940706

Max Phenotype

## [1] 0.3301998

Min Phenotype

## [1] 0.3831788

Population Size

## [1] 0.5742363

What is up with the correlations (7 sec)

notes

Early Simulation Correlation (7 sec)

Mean (7 sec)

## [1] 0.4031636

SD (7 sec)

## [1] -0.04149063

Max Phenotype (7 sec)

## [1] 0.2860037

Min Phenotype (7 sec)

## [1] 0.2452591

Population Size (7 sec)

## [1] -0.2656185

Middle Simulation Correlation

Mean (7 sec)

## [1] 0.1251775

SD (7 sec)

## [1] 0.1103881

Max Phenotype (7 sec)

## [1] 0.0716194

Min Phenotype (7 sec)

## [1] 0.1474161

Population Size (7 sec)

## [1] 0.1387545

Late Simulation Correlation

Mean (7 sec)

## [1] 0.2668241

SD (7 sec)

## [1] 0.1280909

Max Phenotype (7 sec)

## [1] 0.2194371

Min Phenotype (7 sec)

## [1] 0.3367974

Population Size (7 sec)

## [1] 0.2845694